package com.cb.kfc.service.impl;

import com.cb.kfc.dao.IPermissionDao;
import com.cb.kfc.domain.Permission;
import com.cb.kfc.service.IPermissionService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PermissionServiceImpl implements IPermissionService {

    @Autowired
    private IPermissionDao permissionDao;

//    @Override
//    public void deleteById(String id) throws Exception {
//        permissionDao.deleteFromRole_Permission(id);
//        permissionDao.deleteById(id);
//    }
    /**
     * 获得用户的id，批量，或者单个删除会员种类
     */
    public Integer deletePermissionById(String[] ids) {
        if(ids !=null && ids.length>0){
            Integer integer = permissionDao.deleteRP(ids);
            integer = permissionDao.deleteP(ids);
            return integer;
        }
        return 0;
    }

    @Override
    public Permission findById(String id) throws Exception {
        return permissionDao.findById(id);
    }

    @Override
    public void save(Permission permission) throws Exception{
        permissionDao.save(permission);
    }

    @Override
    public List<Permission> findAll(int page,int size) throws Exception{
        PageHelper.startPage(page,size);
        return permissionDao.findAll();
    }
}
